package com.java.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.java.common.utils.PageUtils;
import com.java.common.utils.Query;
import com.java.mapper.CarouselDao;
import com.java.pojo.Carousel;
import com.java.service.CarouselService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("carouselService")
public class CarouselServiceImpl extends ServiceImpl<CarouselDao, Carousel> implements CarouselService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<Carousel> page = this.page(
                new Query<Carousel>().getPage(params),
                // 拼接查询条件
                new LambdaQueryWrapper<Carousel>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<Carousel> queryAll(Integer isShow) {
        return this.baseMapper.selectList(new LambdaQueryWrapper<Carousel>().eq(Carousel::getIsShow,isShow).orderByAsc(Carousel::getSort));
    }

}